package TestDemo;
abstract class Animal {
    String name;
    int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
//跑的接口
interface Run {
    void run();
}
//飞的接口
interface Fly {
    void fly();
}
//游泳的接口
interface Swim {
    void swim();
}
interface amphibious extends Run,Swim {
    //可以自己加上属于自己的抽象方法
    //也可以不去加，默认就是继承的这两个接口
}
class Dog extends Animal implements Run{

    public Dog(String name, int age) {

        super(name, age);
    }

    @Override
    public void run() {
        System.out.println(name+" 用四条腿跑");
    }
}
//乌龟类
class Tortoise extends Animal implements amphibious{

    public Tortoise(String name, int age) {
        super(name, age);
    }
    @Override
    public void run() {
        System.out.println(name+" 用四条腿爬");
    }

    @Override
    public void swim() {
        System.out.println(name+" 用四条腿扑腾");
    }
}

//鸭子类
class Duck extends Animal implements Run,Swim,Fly{

    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void run() {
        System.out.println(name+" 正在用两条腿跑");
    }

    @Override
    public void fly() {
        System.out.println(name+" 正在用翅膀飞");
    }

    @Override
    public void swim() {
        System.out.println(name+" 正在飘在水上");
    }
}
public class Test1 {
    public static void main(String[] args) {

        Dog dog=new Dog("哮天犬",888);
        dog.run();
        System.out.println("===========================");
        Tortoise tortoise=new Tortoise("杰尼龟",88);
        tortoise.run();
        tortoise.swim();
        System.out.println("===========================");
        Duck duck=new Duck("唐老鸭",12);
        duck.run();
        duck.swim();
        duck.fly();
    }
}